// AsioftpDlg.h : header file
//

#pragma once

#include "ftp_client.h"




// CAsioftpDlg dialog
class CAsioftpDlg : public CDialog,
					public ftp_client_listener
{
// Construction
public:
	CAsioftpDlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
	enum { IDD = IDD_ASIOFTP_DIALOG };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support


// Implementation
protected:
	HICON m_hIcon;

	// Generated message map functions
	virtual BOOL OnInitDialog();
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	DECLARE_MESSAGE_MAP()
public:
	afx_msg void OnBnClickedOk();
	ftp_client *pftp_;
	boost::thread *pThread_;
	boost::asio::io_service io_service_;

	ftp_client_listener *listener_;

	CString strIP_;
	CString strPort_;
	CString userName_;
	CString passWord_;
	CListBox *pListBox_;
	std::string info_;
	std::list<std::string> infos_;
	boost::mutex infoLock_;
public:
	virtual void ftpStateCallback(eftpState state,std::string info) ;
	virtual void ftpResponseCallback(eftpState state,
		std::vector<std::string> tcpResponse) ;
	afx_msg void OnBnClickedButton1();
	afx_msg void OnBnClickedButton3();
	afx_msg void OnBnClickedButton4();
	afx_msg void OnBnClickedButton5();
	afx_msg void OnBnClickedButton6();
	afx_msg void OnBnClickedButton2();
	afx_msg void OnBnClickedOk2();
	afx_msg LRESULT OnInfo(WPARAM wParam,LPARAM lParam);
	afx_msg void OnBnClickedButton7();
	afx_msg void OnBnClickedCancel();
};
class listener :public ftp_client_listener{
public:
	listener(CAsioftpDlg *pWnd):pDialog(pWnd){}

	virtual void ftpStateCallback(eftpState state,
		std::string info) 
	{
		// 		OutputDebugStringA("\n");
		// 		OutputDebugStringA(info.c_str());
		pDialog->ftpStateCallback(state,info);
	}


	virtual void ftpResponseCallback(eftpState state,
		std::vector<std::string> tcpResponse) 
	{
		for (std::vector<std::string>::iterator it = tcpResponse.begin();
			it != tcpResponse.end();++it)
		{
			//	OutputDebugStringA((*it).c_str());
			pDialog->ftpResponseCallback(state,tcpResponse);
		}
	}
	CAsioftpDlg *pDialog;
};